//package com.hzhc.config;
//
//import cn.hutool.core.util.StrUtil;
//import com.alibaba.fastjson2..JSONUtil;
//import com.hzhc.util.GzipUtil;
//import com.hzhc.vo.ResultVo;
//import org.springframework.core.MethodParameter;
//import org.springframework.http.HttpInputMessage;
//import org.springframework.http.converter.HttpMessageConverter;
//import org.springframework.stereotype.Component;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice;
//
//import java.io.IOException;
//import java.lang.reflect.Type;
//
///**
// * @ClassName: GlobalRequestBodyAdvice
// * @Description:请求参数的操作 RequestBodyAdvice可以理解为在@RequestBody之前需要进行的操作
// * @version 1.0
// * @author: duanhm
// * @Date: 2023/11/17 19:58:07
// *
// */
//
//@Component
//@ControllerAdvice(basePackages = "com.hzhc.controller")
//public class GlobalRequestBodyAdvice implements RequestBodyAdvice {
//
//	@Override
//	public boolean supports(MethodParameter methodParameter, Type targetType,
//			Class<? extends HttpMessageConverter<?>> converterType) {
//
//		return true;
//	}
//
//	@Override
//	public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
//			Class<? extends HttpMessageConverter<?>> converterType) throws IOException {
//
//		return inputMessage;
//	}
//
//	@Override
//	public Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
//			Class<? extends HttpMessageConverter<?>> converterType) {
//		// TODO Auto-generated method stub
//		if (body != null) {
//			String jsonstr = JSONUtil.toJsonPrettyStr(body);
//			ResultVo vo = JSONUtil.toBean(jsonstr, ResultVo.class);
//			if (vo != null && StrUtil.isNotBlank(vo.getData())) {
//				String ret = GzipUtil.ungzip(vo.getData());
//				return ret;
//			}
//		}
//		return body;
//	}
//
//	@Override
//	public Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter,
//			Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//}
